<?php
if($_GET['get']=='blog'){
		$cache = new Cache();
		$sql ="select id, post_id, is_text,views,likes,comments from index_post where is_text=1  order by id DESC";
		$sql2="select id from index_post where is_text=1 order by id DESC limit 0,10";
			
		$pager = new Pagination($sql,10,4,'',0,"post");

	
		$data['blog'] = $pager->paginate($cache,$sql2);
		$data2=array();
		foreach($data['blog'] as $row){
		$row2['id']=$row['pid'];
		$row2['title']=$row['title'];
		$row2['alias']=$row['alias'];
		$row2['url']=url_post($row['pid'],$row['alias'],'blog');
		$data2[]=$row2;
		}
			echo json_encode($data2);
}
if($_GET['get']=='video'){
	
$cache = new Cache();
		$sql ="select id, post_id, is_video,views,likes,comments from index_post where is_video=1  order by id DESC";
		$sql2="select id from index_post where is_video=1 order by id DESC limit 0,10";
			
		$pager = new Pagination($sql,10,4,'',0,"post");

	
		$data['video'] = $pager->paginate($cache,$sql2);
		$data2=array();
		foreach($data['video'] as $row){
		$row2['id']=$row['pid'];
		$row2['title']=$row['title'];
		$row2['alias']=$row['alias'];
		$row2['url']=url_post($row['pid'],$row['alias'],'video');
		$data2[]=$row2;
		}
		echo json_encode($data2);
	
		
}
if($_GET['get']=='ngontinh'){
				$cache = new Cache();
				$sql3="select * from truyen_theloai_fk where theloai_id=3 order by truyen_id desc";
				$sql4="select truyen_id from truyen_theloai_fk where theloai_id=3";
				$pager2 = new Pagination($sql3,10,4,'',300,"truyen_2");
				$pager2->setDebug(false);
				$data['ngontinh'] = $pager2->paginate($cache,$sql4);
				
				$data2=array();
				foreach($data['ngontinh'] as $row){
				$row2['chuongmoinhat']=short_str($row['chuongmoinhat'],20);
				$row2['id']=$row['id'];
				$row2['title']=short_str($row['ten'],25);
				$row2['alias']=$row['alias'];
				$row2['url']=url_truyen($row['id'],$row['alias']);
				$data2[]=$row2;
				}
				echo json_encode($data2);
				
}

if($_GET['get']=='truyen'){
					$cache = new Cache();
					$sql ="select id from truyen  where duyet=1 order by time_update desc ";
					$sql2="select id from truyen where duyet=1 ";
					$pager = new Pagination($sql,10,4,'',0,"truyen_1");
					$pager->setDebug(false);
					$data['truyenmoi'] = $pager->paginate($cache,$sql2);
				$data2=array();
				
				foreach($data['truyenmoi'] as $row){
				$row2['chuongmoinhat']=short_str($row['chuongmoinhat'],20);
				$row2['id']=$row['id'];
				$row2['title']=short_str($row['ten'],25);
				$row2['alias']=$row['alias'];
				$row2['url']=url_truyen($row['id'],$row['alias']);
				$data2[]=$row2;
				}
				echo json_encode($data2);
				
}

exit();
?>